/*
 * Copyright © 2019 by MaShibo. All Rights Reserved.
 */

package mashibo.project.etc.assistant.utils;

/**
 * 编码工具类
 */
public class EncodingUtil {


    private EncodingUtil() {
        throw new IllegalStateException();
    }


    public static byte[] HexStringToBytes(String str) {
        int nLen = str.length();
        byte[] bytes = new byte[str.length() / 2];

        for (int i = 0; i < nLen / 2; ++i) {
            bytes[i] = hexStringToByte(str.substring(i * 2, i * 2 + 2));
        }

        return bytes;
    }


    public static byte hexStringToByte(String str) {
        return (byte) Integer.parseInt(str, 16);
    }
}
